<?php

namespace Addons\IcWaterGoods\Model;
use Think\Model;

/**
 * Zmphoto模型
 */
class PublicModel extends Model{

    //获取记录集
    public function getListAll($field='',$where=null,$join=false,$order='id'){
        if(empty($where['status']))$where['status'] = 1;
        $where['mpid']  = get_mpid();
        return $this
            ->join($join)
            ->where($where)
            ->field($field)
            ->order($order)
            ->select();
    }

    //获取单条记录
    public function getOne($where,$field='',$join=false){
        if(empty($where['status']))$where['status'] = 1;
        $where['mpid']  = get_mpid();
        return $this->join($join)->where($where)->field($field)->find();
    }

    //获取字段
    public function getFie($where,$field){
        if(empty($where['status']))$where['status'] = 1;
        $where['mpid']  = get_mpid();
        return $this->where($where)->getField($field);
    }

    //设置字段
    public function setFie($where,$field,$value){
        if(empty($where['status']))$where['status'] = 1;
        $where['mpid']  = get_mpid();
        return $this->where($where)->setField($field,$value);
    }


    //数据更新
    public function update($where,$data){
        $data['update_time'] = time();
        $ok = $this->where($where)->save($data);
        return  $ok;
    }

    /*添加数据*/
    public function addData($data){
        $data['mpid']  = get_mpid();
        $data['create_time'] = time();
        return $this->add($data);
    }

}
